﻿/*去除字符串左右空格*/
String.prototype.trim = function () {
    return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

/*设置焦点*/
function setFocus(objID) {
    var obj = document.getElementById(objID);
    if (obj != null && obj != undefined) {
        obj.focus();
    }
}

/*解密密码*/
function DecrPwd(objID, depwdid) {
    var tpwd = $("#" + objID).val();
    if (tpwd.trim() == "") {
        $("#" + objID).css('border', '1px solid red');
        $("#" + objID).val("");
        $("#" + objID).focus();
    } else {
    $.ajax({
        type: "POST",
        url: "../Admin/ASHX/DecryptionPwd.ashx",
        dataType: "json",
        data: { pwd: tpwd },
        success: function (ret) {
            if (ret.IsTrue = true) {
                $("#" + depwdid).val(ret.DePwd);
            } else {
                alert("解密错误：" + ret.DePwd + "\n请输入有效的加密后的字符串！");
            }
        },
        error: function (ret) {
            alert("服务器错误，请稍后再试！");
        }
    })
    }
}